#!/bin/sh 
#/usr/local/tomcat
#/usr/local/nginx/sbin/nginx 
echo ">>>>>>>>>>begin install <<<<<<<<<"
mkdir -p /home/install
cd /home/install
#echo ">>>>>>>>>>install dos2unix<<<<<<<<<"
#if [[ -n $(yum list installed |grep dos2unix) ]]; then
#    echo "已安装dos2unix" 
#else
#    yum -y install dos2unix
#    echo "安装dos2unix完毕" 
#fi
echo ">>>>>>>>>>install jdk8<<<<<<<<<"
if [[ -n $(yum list installed |grep jdk) ]]; then
    echo "已安装jdk" 
else
    cd /home/install
    #wget -O jdk-8u181-linux-x64.rpm --no-cookie --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm
    wget -O jdk-8u181-linux-x64.rpm https://cd-1251357415.cos.ap-chengdu.myqcloud.com/jdk/jdk-8u181-linux-x64.rpm
    echo ">>>>>>>>>>install jre8<<<<<<<<<"
    rpm -ivh jdk-8u181-linux-x64.rpm
    echo "安装jdk完毕" 
fi
echo ">>>>>>>>>>install nginx1.14<<<<<<<<<"
if test -e /usr/local/nginx/sbin/nginx; then 
    echo "已安装nginx" 
else
    cd /home/install
    wget -O installNginx1.14 https://gitee.com/thx/shell/raw/master/nginx/installNginx1.14
#    dos2unix installNginx1.14
    chmod a+x installNginx1.14
    ./installNginx1.14
    echo "安装nginx完毕" 
fi
echo ">>>>>>>>>>install tomcat8.5<<<<<<<<<"
if test -e /usr/local/tomcat/apache-tomcat-8.5.33/bin/startup.sh; then 
    echo "已安装tomcat" 
else
    cd /home/install
    mkdir -p /usr/local/tomcat
    wget -O apache-tomcat-8.5.33.tar.gz https://cd-1251357415.cos.ap-chengdu.myqcloud.com/tomcat/apache-tomcat-8.5.33.tar.gz
    tar -zxvf apache-tomcat-8.5.33.tar.gz -C /usr/local/tomcat
    echo "已安装tomcat完毕" 
fi
echo ">>>>>>>>>>install mysql5.7 <<<<<<<<<"
if [[ -n $(yum list installed |grep mysql) ]]; then
    echo "已安装mysql" 
else
    cd /home/install
    wget -O mysql57-community-release-el7-11.noarch.rpm https://cd-1251357415.cos.ap-chengdu.myqcloud.com/mysql/mysql57-community-release-el7-11.noarch.rpm
    rpm -ivh mysql57-community-release-el7-11.noarch.rpm
    yum -y install mysql-community-server 
    chown mysql.mysql /var/run/mysqld/
    chown mysql:mysql -R /var/lib/mysql
    systemctl start mysqld
    echo "安装mysql完毕" 
fi
echo ">>>>>>>>>>end install <<<<<<<<<"
